<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>
<?php include 'submitdatabaseinfo.php';?>
<?php
$lang = $_GET['lang'];
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
mysqli_set_charset($conn, "utf8");
// Check connection
if (!$conn) {
  die("Database connection failed: " . mysqli_connect_error());
}

$sql = "SELECT title, primarykey FROM stories WHERE checked = 'yes' AND language = '".$lang."'";
$result = mysqli_query($conn,$sql);
$rows = mysqli_num_rows($result);
if ( $rows > 0 ) {
  echo "<tr><th></th><th>Choose the title of the story you wish to read</th></tr>";
  while($row = mysqli_fetch_array($result)){
        echo "<tr> <td> <input type='radio' name='storytitles' value='" . $row["primarykey"] . "' onclick='getstory(" . $row["primarykey"] . ")'> </td> <td id='" . $row["primarykey"] . "'>" . $row["title"] . "</td></tr>";
  }
} else {
  echo "<tr><th></th><th>There are no stories in this language</th></tr>";
}
 
mysqli_close($conn);
exit;
?>
</body>
</html>
